using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityMovementAI;


namespace UnityMovementAI
{
public class SeekPositionUnit : MonoBehaviour
{
    public Vector3 targetPosition;

    [Header("运行时")]
    public bool bIsActive = false;
    private SteeringBasics steeringBasics;
    void Start()
    {
        steeringBasics = GetComponent<SteeringBasics>();
    }

    void FixedUpdate()
    {
        if (!bIsActive) return;
        Vector3 accel = steeringBasics.Seek(targetPosition);

        steeringBasics.Steer(accel);
        steeringBasics.LookWhereYoureGoing();
    }

    public bool IsArrived(){
        return Vector3.Distance(transform.position, targetPosition) < 0.1f;
    }
    public void SetActive(bool bActive){
        bIsActive = bActive;
    }
}
}